/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultaDlg.java
 *
 * Created on 05-ene-2012, 0:57:53
 */
package vista.personas.pacientes;

import java.util.Collection;
import javax.swing.DefaultListModel;
import javax.swing.JFormattedTextField;
import util.GestorComponenteVista;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.*;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeSelectionModel;
import modelo.patologias.Enfermedad;
import modelo.patologias.TipoEnfermedad;
import org.japura.gui.model.DefaultListCheckModel;
import util.components.EditorHTML;
import util.components.IntegerTextField;
import util.validation.annotation.NotEmpty;

/**
 *
 * @author Raul
 */
public class ConsultaDlg extends javax.swing.JDialog {
     
    private GestorVistaConsultaDlg gestorVista;
    
    /** Creates new form ConsultaDlg */
    public ConsultaDlg(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
    }
    
    public ConsultaDlg( GestorVistaConsultaDlg gestorVista) {
        super();
        this.gestorVista = gestorVista;
        initComponents();
        setLocationRelativeTo(null);
    }

    public JFormattedTextField getAlturaTxt() {
        return alturaTxt;
    }

    @NotEmpty(mensaje="Debe diagnosticar alguna enfermedad para el paciente")
    public JFormattedTextField getEnfermedadTxt() {
        return enfermedadTxt;
    }

    public JFormattedTextField getFechaDiagnosticoTxt() {
        return fechaDiagnosticoTxt;
    }

    public IntegerTextField getFrecuenciaCardiacaTxt() {
        return frecuenciaCardiacaTxt;
    }

    public IntegerTextField getFrecuenciaRespiratoriaTxt() {
        return frecuenciaRespiratoriaTxt;
    }

    public EditorHTML getInspeccionGeneralTxt() {
        return inspeccionGeneralTxt;
    }

    public EditorHTML getPadecimientoTxt() {
        return padecimientoTxt;
    }

    public JFormattedTextField getPesoIdealTxt() {
        return pesoIdealTxt;
    }

    public JFormattedTextField getPesoTxt() {
        return pesoTxt;
    }

    public EditorHTML getPlanTxt() {
        return planTxt;
    }

    @NotEmpty
    public JComboBox getProfesionalCmb() {
        return profesionalCmb;
    }

    public IntegerTextField getPulsoTxt() {
        return pulsoTxt;
    }

    public JList getSintomasLst() {
        return sintomasLst;
    }

    public IntegerTextField getTemperaturaTxt() {
        return temperaturaTxt;
    }

    public JTextField getTensionArterialTxt() {
        return tensionArterialTxt;
    }
    
    public void cargarComboProfesionales(Collection profesionales) {
        GestorComponenteVista.cargarCombo(profesionalCmb, profesionales);
    }
    
    public void crearModeloArbol(TreeModel model){
        GestorComponenteVista.crearModeloArbol(enfermedadesTree, model);
    }
    
    void cargarListaSintomas(Collection sintomas) {
        GestorComponenteVista.cargarLista(sintomasLst, sintomas);
    }
    
    void agregarNodoArbol(TipoEnfermedad tipoEnfermedad, Enfermedad e) {
        GestorComponenteVista.agregarNodoArbol(enfermedadesTree, tipoEnfermedad, e);
    }
    
    void cargarCheckListSintomas(List sintomas) {
        DefaultListCheckModel model = new DefaultListCheckModel();
        sintomasChk.setModel(model);
        Iterator i = sintomas.iterator();
        while (i.hasNext()){
            model.addElement(i.next());
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        selectorSintomasDlg = new javax.swing.JDialog();
        jPanel4 = new javax.swing.JPanel();
        acceptBtn = new javax.swing.JButton();
        declineBtn = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        sintomasChk = new org.japura.gui.CheckList();
        jButton1 = new javax.swing.JButton();
        cuerpoPnl = new util.components.GradientPanel();
        jLabel1 = new javax.swing.JLabel();
        profesionalCmb = new javax.swing.JComboBox();
        fechaDiagnosticoTxt = new javax.swing.JFormattedTextField();
        jLabel18 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        padecimientoTxt = new util.components.EditorHTML();
        sintomasPnl = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        sintomasLst = new javax.swing.JList();
        jToolBar1 = new javax.swing.JToolBar();
        addSintomaBtn = new javax.swing.JButton();
        quitarSintomaBtn = new javax.swing.JButton();
        exploracionFisicaPnl = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        frecuenciaRespiratoriaTxt = new util.components.IntegerTextField();
        temperaturaTxt = new util.components.IntegerTextField();
        frecuenciaCardiacaTxt = new util.components.IntegerTextField();
        jLabel10 = new javax.swing.JLabel();
        pulsoTxt = new util.components.IntegerTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        pesoTxt = new AuxTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        pesoIdealTxt = new AuxTextField();
        alturaTxt = new AuxTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        tensionArterialTxt = new javax.swing.JTextField();
        inspeccionGeneralTxt = new util.components.EditorHTML();
        diagnosticoPnl = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        enfermedadesTree = new javax.swing.JTree();
        buscarEnfermedadTxt = new javax.swing.JTextField();
        buscarEnfermedadBtn = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        enfermedadTxt = new javax.swing.JFormattedTextField();
        diagnosticarBtn = new javax.swing.JButton();
        consultarEnfermedadesProbablesBtn = new javax.swing.JButton();
        planTxt = new util.components.EditorHTML();
        cancelarBtn = new javax.swing.JButton();
        listoBtn = new javax.swing.JButton();

        selectorSintomasDlg.setTitle("Sintomas");
        selectorSintomasDlg.setBackground(java.awt.Color.white);
        selectorSintomasDlg.setModal(true);
        selectorSintomasDlg.setUndecorated(true);

        jPanel4.setBorder(new util.components.RoundedBorder());

        acceptBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/accept.png"))); // NOI18N
        acceptBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acceptBtnActionPerformed(evt);
            }
        });

        declineBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/delete_24.png"))); // NOI18N
        declineBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                declineBtnActionPerformed(evt);
            }
        });

        sintomasChk.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
        jScrollPane5.setViewportView(sintomasChk);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane5)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(0, 702, Short.MAX_VALUE)
                        .addComponent(acceptBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(declineBtn)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(declineBtn)
                    .addComponent(acceptBtn))
                .addGap(6, 6, 6))
        );

        javax.swing.GroupLayout selectorSintomasDlgLayout = new javax.swing.GroupLayout(selectorSintomasDlg.getContentPane());
        selectorSintomasDlg.getContentPane().setLayout(selectorSintomasDlgLayout);
        selectorSintomasDlgLayout.setHorizontalGroup(
            selectorSintomasDlgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        selectorSintomasDlgLayout.setVerticalGroup(
            selectorSintomasDlgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        selectorSintomasDlg.pack();
        GestorComponenteVista.centrarVentana(selectorSintomasDlg);

        jButton1.setText("jButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Diagnóstico");
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setModal(true);
        setResizable(false);

        cuerpoPnl.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.lightGray));
        cuerpoPnl.setGradientColor1(java.awt.Color.white);
        cuerpoPnl.setGradientColor2(javax.swing.UIManager.getDefaults().getColor("Panel.background"));

        jLabel1.setText("Profesional");

        profesionalCmb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        profesionalCmb.setOpaque(false);

        fechaDiagnosticoTxt.setEditable(false);
        fechaDiagnosticoTxt.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        fechaDiagnosticoTxt.setOpaque(false);
        fechaDiagnosticoTxt.setValue(new Date());

        jLabel18.setText("Fecha Diagnóstico");

        padecimientoTxt.setOpaque(false);
        jTabbedPane1.addTab("Padecimiento", padecimientoTxt);

        sintomasPnl.setOpaque(false);
        sintomasPnl.setLayout(new java.awt.GridBagLayout());

        sintomasLst.setModel(new DefaultListModel());
        sintomasLst.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        sintomasLst.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
        sintomasLst.setVisibleRowCount(4);
        jScrollPane4.setViewportView(sintomasLst);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 344;
        gridBagConstraints.ipady = 119;
        gridBagConstraints.weightx = 0.4;
        gridBagConstraints.weighty = 1.0;
        sintomasPnl.add(jScrollPane4, gridBagConstraints);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setOpaque(false);

        addSintomaBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/ArrowDown_24.png"))); // NOI18N
        addSintomaBtn.setToolTipText("Agregar síntoma");
        addSintomaBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addSintomaBtnActionPerformed(evt);
            }
        });
        jToolBar1.add(addSintomaBtn);

        quitarSintomaBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/ArrowUp_24.png"))); // NOI18N
        quitarSintomaBtn.setToolTipText("Quitar síntoma");
        quitarSintomaBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitarSintomaBtnActionPerformed(evt);
            }
        });
        jToolBar1.add(quitarSintomaBtn);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        sintomasPnl.add(jToolBar1, gridBagConstraints);

        jTabbedPane1.addTab("Sintomas", sintomasPnl);

        exploracionFisicaPnl.setOpaque(false);

        jLabel2.setText("Tn Arterial");

        jLabel3.setText("Fr Cardiaca");

        jLabel4.setText("Pulso");

        jLabel5.setText("Fr Respiratoria");

        jLabel6.setText("Temperatura");

        jLabel7.setText("Peso");

        jLabel8.setText("ºC");

        jLabel9.setText("/min");

        jLabel10.setText("/min");

        jLabel11.setText("/min");

        jLabel12.setText("mmHg");

        pesoTxt.setValue(new Double(-1));

        jLabel13.setText("Altura");

        jLabel14.setText("Peso Ideal");

        pesoIdealTxt.setValue(new Double(-1));

        alturaTxt.setValue(new Double(-1));

        jLabel15.setText("Kg");

        jLabel16.setText("m");

        jLabel17.setText("Kg");

        javax.swing.GroupLayout exploracionFisicaPnlLayout = new javax.swing.GroupLayout(exploracionFisicaPnl);
        exploracionFisicaPnl.setLayout(exploracionFisicaPnlLayout);
        exploracionFisicaPnlLayout.setHorizontalGroup(
            exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(exploracionFisicaPnlLayout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addGap(12, 12, 12)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(temperaturaTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                    .addComponent(frecuenciaRespiratoriaTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                    .addComponent(pulsoTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                    .addComponent(frecuenciaCardiacaTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                    .addComponent(tensionArterialTxt))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(exploracionFisicaPnlLayout.createSequentialGroup()
                        .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(exploracionFisicaPnlLayout.createSequentialGroup()
                                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel11))
                                .addGap(26, 26, 26)
                                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel13)))
                            .addComponent(jLabel9))
                        .addGap(21, 21, 21)
                        .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(pesoTxt, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(pesoIdealTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(alturaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(21, 21, 21))
        );
        exploracionFisicaPnlLayout.setVerticalGroup(
            exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(exploracionFisicaPnlLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel2)
                    .addComponent(jLabel12)
                    .addComponent(jLabel7)
                    .addComponent(pesoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(tensionArterialTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel3)
                    .addComponent(frecuenciaCardiacaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(alturaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)
                        .addComponent(jLabel16)))
                .addGap(11, 11, 11)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel4)
                    .addComponent(pulsoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(pesoIdealTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(exploracionFisicaPnlLayout.createSequentialGroup()
                            .addGap(5, 5, 5)
                            .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel17)
                                .addComponent(jLabel14)))))
                .addGap(6, 6, 6)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel5)
                    .addComponent(frecuenciaRespiratoriaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(6, 6, 6)
                .addGroup(exploracionFisicaPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel6)
                    .addComponent(temperaturaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(5, 5, 5))
        );

        jTabbedPane1.addTab("Exploración Física", exploracionFisicaPnl);

        inspeccionGeneralTxt.setOpaque(false);
        inspeccionGeneralTxt.setPreferredSize(new java.awt.Dimension(250, 155));
        jTabbedPane1.addTab("Inspección General", inspeccionGeneralTxt);

        diagnosticoPnl.setOpaque(false);

        enfermedadesTree.setRootVisible(false);
        enfermedadesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        jScrollPane1.setViewportView(enfermedadesTree);

        buscarEnfermedadTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarEnfermedadBtnActionPerformed(evt);
            }
        });

        buscarEnfermedadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/zoom.png"))); // NOI18N
        buscarEnfermedadBtn.setToolTipText("Buscar Enfermedad");
        buscarEnfermedadBtn.setBorderPainted(false);
        buscarEnfermedadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarEnfermedadBtnActionPerformed(evt);
            }
        });

        jLabel19.setText("Dx:");

        enfermedadTxt.setEditable(false);
        enfermedadTxt.setToolTipText("Enfermedad Diagnosticada");
        enfermedadTxt.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);

        diagnosticarBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/pathology_add_24.png"))); // NOI18N
        diagnosticarBtn.setText("<html>Diagnosticar<br>Enfermedad<br>seleccionada</html>");
        diagnosticarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                diagnosticarBtnActionPerformed(evt);
            }
        });

        consultarEnfermedadesProbablesBtn.setText("<html>Consultar<br>Enfermedades<br> Probables</html>");
        consultarEnfermedadesProbablesBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consultarEnfermedadesProbablesBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout diagnosticoPnlLayout = new javax.swing.GroupLayout(diagnosticoPnl);
        diagnosticoPnl.setLayout(diagnosticoPnlLayout);
        diagnosticoPnlLayout.setHorizontalGroup(
            diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(enfermedadTxt))
                    .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                        .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                                .addComponent(buscarEnfermedadTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(buscarEnfermedadBtn))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(consultarEnfermedadesProbablesBtn)
                            .addComponent(diagnosticarBtn))))
                .addContainerGap())
        );
        diagnosticoPnlLayout.setVerticalGroup(
            diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(buscarEnfermedadTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buscarEnfermedadBtn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addGroup(diagnosticoPnlLayout.createSequentialGroup()
                        .addComponent(consultarEnfermedadesProbablesBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(diagnosticarBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(diagnosticoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(enfermedadTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Diagnóstico", diagnosticoPnl);
        jTabbedPane1.addTab("Plan", planTxt);

        javax.swing.GroupLayout cuerpoPnlLayout = new javax.swing.GroupLayout(cuerpoPnl);
        cuerpoPnl.setLayout(cuerpoPnlLayout);
        cuerpoPnlLayout.setHorizontalGroup(
            cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cuerpoPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cuerpoPnlLayout.createSequentialGroup()
                        .addGroup(cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(cuerpoPnlLayout.createSequentialGroup()
                                .addComponent(fechaDiagnosticoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(profesionalCmb, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(cuerpoPnlLayout.createSequentialGroup()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        cuerpoPnlLayout.setVerticalGroup(
            cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cuerpoPnlLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel18)
                    .addComponent(fechaDiagnosticoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(cuerpoPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(profesionalCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        cancelarBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/cancel.png"))); // NOI18N
        cancelarBtn.setText("Cancelar");
        cancelarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarBtnActionPerformed(evt);
            }
        });

        listoBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/accept.png"))); // NOI18N
        listoBtn.setText("Listo");
        listoBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listoBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(listoBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelarBtn)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(cuerpoPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(cuerpoPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(listoBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cancelarBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarBtnActionPerformed
        dispose();
    }//GEN-LAST:event_cancelarBtnActionPerformed

    private void listoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listoBtnActionPerformed
        gestorVista.guardar();
    }//GEN-LAST:event_listoBtnActionPerformed

    private void addSintomaBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addSintomaBtnActionPerformed
        gestorVista.agregarSintomas(GestorComponenteVista.getObjetosEnLista(sintomasLst));
        selectorSintomasDlg.setVisible(true);
    }//GEN-LAST:event_addSintomaBtnActionPerformed

    private void quitarSintomaBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitarSintomaBtnActionPerformed
        if (!sintomasLst.isSelectionEmpty()) {
            GestorComponenteVista.quitarDatoLista(sintomasLst, sintomasLst.getSelectedIndex());
        }
    }//GEN-LAST:event_quitarSintomaBtnActionPerformed

    private void acceptBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptBtnActionPerformed
        GestorComponenteVista.agregarDatosLista(sintomasLst, GestorComponenteVista.getObjetosEnLista(sintomasChk));
        selectorSintomasDlg.setVisible(false);
    }//GEN-LAST:event_acceptBtnActionPerformed

    private void declineBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_declineBtnActionPerformed
        selectorSintomasDlg.dispose();
    }//GEN-LAST:event_declineBtnActionPerformed

    private void buscarEnfermedadBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarEnfermedadBtnActionPerformed
        gestorVista.buscarEnfermedad(buscarEnfermedadTxt.getText());
        GestorComponenteVista.expandirArbol(enfermedadesTree);
    }//GEN-LAST:event_buscarEnfermedadBtnActionPerformed

    private void diagnosticarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_diagnosticarBtnActionPerformed
        if (!enfermedadesTree.isSelectionEmpty() &&
                GestorComponenteVista.isHojaSeleccionada(enfermedadesTree)) {
            enfermedadTxt.setValue(GestorComponenteVista.getObjetoSeleccionado(enfermedadesTree));
        }
    }//GEN-LAST:event_diagnosticarBtnActionPerformed

    private void consultarEnfermedadesProbablesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consultarEnfermedadesProbablesBtnActionPerformed
        gestorVista.consultarEnfermedadesProbables();
        GestorComponenteVista.expandirArbol(enfermedadesTree);
    }//GEN-LAST:event_consultarEnfermedadesProbablesBtnActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ConsultaDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ConsultaDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ConsultaDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ConsultaDlg.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                ConsultaDlg dialog = new ConsultaDlg(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton acceptBtn;
    private javax.swing.JButton addSintomaBtn;
    private javax.swing.JFormattedTextField alturaTxt;
    private javax.swing.JButton buscarEnfermedadBtn;
    private javax.swing.JTextField buscarEnfermedadTxt;
    private javax.swing.JButton cancelarBtn;
    private javax.swing.JButton consultarEnfermedadesProbablesBtn;
    private util.components.GradientPanel cuerpoPnl;
    private javax.swing.JButton declineBtn;
    private javax.swing.JButton diagnosticarBtn;
    private javax.swing.JPanel diagnosticoPnl;
    private javax.swing.JFormattedTextField enfermedadTxt;
    private javax.swing.JTree enfermedadesTree;
    private javax.swing.JPanel exploracionFisicaPnl;
    private javax.swing.JFormattedTextField fechaDiagnosticoTxt;
    private util.components.IntegerTextField frecuenciaCardiacaTxt;
    private util.components.IntegerTextField frecuenciaRespiratoriaTxt;
    private util.components.EditorHTML inspeccionGeneralTxt;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton listoBtn;
    private util.components.EditorHTML padecimientoTxt;
    private javax.swing.JFormattedTextField pesoIdealTxt;
    private javax.swing.JFormattedTextField pesoTxt;
    private util.components.EditorHTML planTxt;
    private javax.swing.JComboBox profesionalCmb;
    private util.components.IntegerTextField pulsoTxt;
    private javax.swing.JButton quitarSintomaBtn;
    private javax.swing.JDialog selectorSintomasDlg;
    private org.japura.gui.CheckList sintomasChk;
    private javax.swing.JList sintomasLst;
    private javax.swing.JPanel sintomasPnl;
    private util.components.IntegerTextField temperaturaTxt;
    private javax.swing.JTextField tensionArterialTxt;
    // End of variables declaration//GEN-END:variables


}

class AuxTextField extends JFormattedTextField {
 
        @Override
        public String getText() {
            return !super.getText().equals("")?super.getText():"-1";
        }

        @Override
        public void setText(String t) {
            if (!t.equals("-1"))
                super.setText(t);
            else
                super.setText("");
        }
        
    }
